fix: report which half of a JAX first call is stalled - #1529
Merged
Conversation
The first call to a jax.jit/vmap/grad wrapper contains two waits -- trace/lower/compile, then jax.block_until_ready execution -- and the instrumentation could not tell a stalled run which one it was in. Two defects, both of which made a stall report the wrong diagnosis: 1. The heartbeat hardcoded "still compiling". A stalled CI run therefore logged `JAX jit still compiling ... 1770s elapsed` while its captured faulthandler stack sat in jax.block_until_ready. That is positive evidence for the wrong cause, and five quarantine markers across the two test workspaces were written against it, all calling this an "intermittent XLA compile stall". It is not one: compilation completes, in ~16s, and execution never returns. 2. The compile/execute split line was emitted only after BOTH halves finished. A stalled run never finishes the second, so it reported neither number and the split characterised only the healthy case -- twenty stalled runs could not say that compilation had in fact completed. Now: the compile half is logged the instant func() returns, the heartbeat moves to naming the materialize half and repeats the compile time on every beat, and the materialize half is logged on its own when it lands. A run SIGKILLed at any point after tracing has already said on stderr which half it was in and how long the other took. Also extracts _block_until_ready() so the execution half is substitutable in tests without JAX installed, and so the broad `except Exception` guards only the optional jax import rather than the wait itself. No call site changes: all four (Fitness._vmap/_jit/_grad, analysis/latent) inherit this through log_on_first_compile. For PyAutoFit#1528 (jax-compile-stall phase 3); follows #1517/#1518. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes part of #1528 (phase 3 of the
jax-compile-stallepic). Library leg — merges first; the two workspace PRs consume it.The problem
The first call to a
jax.jit/vmap/gradwrapper contains two waits — trace/lower/compile, thenjax.block_until_readyexecution — and the instrumentation could not tell a stalled run which one it was in.Two defects, both of which made a stall report the wrong diagnosis.
The heartbeat hardcoded
"still compiling". A stalled CI run therefore loggedJAX jit still compiling ... 1770s elapsedwhile its stack sat injax.block_until_ready. That is positive evidence for the wrong cause, and five quarantine markers across the two test workspaces were written against it, every one calling this an "intermittent XLA compile stall". It is not one — compilation completes, in ~12–18s, and execution never returns.The compile/execute split was emitted only after BOTH halves finished. A stalled run never finishes the second, so it reported neither number and the split characterised only the healthy case. Twenty stalled runs could not say that compilation had in fact completed.
The change
The compile half is logged the instant
func()returns. The heartbeat then names the materialize half it has moved into and repeats the compile time on every beat — a stalled run is SIGKILLed and reaches no summary line, so whatever beat last got to stderr has to carry the split by itself.Also extracts
_block_until_ready()so the execution half is substitutable in tests without JAX installed (the library suite is numpy-only, so the real path cannot produce a hang), and so the pre-existing broadexcept Exceptionguards only the optionalimport jaxrather than swallowing failures from the wait itself.No call site changes — all four (
Fitness._vmap/_jit/_grad,analysis/latent) inherit this throughlog_on_first_compile.This is what found the bug
From autolens_workspace_test run 33076408637, verbatim:
On the old code that identical run reads
still compiling ... 270s elapsedand produces a sixth marker with the wrong name. The campaign's root cause was found in the hours after this landed.Tests
Five new, all asserting relationships rather than wordings — the trap #1517 recorded, where its own tests could not catch a 300s dump default colliding with a 300s cap:
_block_until_readystays a no-op when JAX is absenttest_jax_compile.py23 passed. Full suite 2224 passed, 3 skipped.Heart
Not consulted —
pyauto-heartis unreachable from theweb-githubenvironment, as recorded on phases 1 and 2 of this epic.Generated by Claude Code